<template>
    <div>
        <el-table :data="tableData" style="width: 100%" :default-sort="{ prop: 'date', order: 'descending' }">
            <el-table-column prop="date" label="编号" sortable width="180">
            </el-table-column>
            <el-table-column prop="name" label="程度" sortable width="180">
            </el-table-column>
            <el-table-column prop="address" label="类别" >
            </el-table-column>
            <el-table-column prop="address" label="标题" >
            </el-table-column>
            <el-table-column prop="address" label="当前节点" >
            </el-table-column>
            <el-table-column prop="address" label="发起时间" >
            </el-table-column>
            <el-table-column prop="address" label="到期时间" >
            </el-table-column>
            <el-table-column prop="date" label="状态" sortable width="180"></el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" @click="lookOver">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pager :page=page :limit=limit :total=total :lastPage=lastPage @handleSizeChange="handleSizeChange"
            @toLastPage="toLastPage" @toFirstPage="toFirstPage" @handleCurrentChange="handleCurrentChange"></pager>

</div>
</template>

<script>
import pager from "../components/pager.vue";

export default {
    name: "mySendList",
    data() {
        return {
            tableData: [{
                date: '2016-05-02',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-04',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1517 弄'
            }, {
                date: '2016-05-01',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1519 弄'
            }, {
                date: '2016-05-03',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1516 弄'
            }],
            page: 1,
            limit: 3,
            lastPage: 0,
            total: 0,
            currentPageData: [], //当前页显示内容
        }
    },
    components: {
        pager,

    },
    methods: {
        handleSizeChange(val) {
            this.limit = val;
            this.lastPage = Math.ceil(this.tableData.length / this.limit);
            this.getCurrentPageData()
        },
        getCurrentPageData() {
            let begin = (this.page - 1) * this.limit;
            let end = this.page * this.limit;
            this.currentPageData = this.tableData.slice(begin, end)
        },
        toLastPage(val) {
            this.page = val;
            this.getCurrentPageData()
        },
        toFirstPage(val) {
            this.page = val;
            this.getCurrentPageData()
        },
        handleCurrentChange(val) {
            this.page = val;
            this.getCurrentPageData(val)
        },
        lookOver(){
            this.$router.push("/sendView")
        }
    },
    created() {
        this.lastPage = Math.ceil(this.tableData.length / this.limit)
        this.total = this.tableData.length
        this.getCurrentPageData();
    }


}
</script>

<style  scoped></style>